package com.ebo.learn_demo

import androidx.annotation.CheckResult
import androidx.annotation.IntDef

/**
 * @author zmp
 * @date : 2021/12/10 16:48
 * des:IMathApi
 */
interface IMathApi {
    @IMethod(values = IMethodType.METHOD_ADD)
    fun <T : Number> methodAdd(vararg parameters: T): T

    @IMethod(values = IMethodType.METHOD_MINUS)
    fun <T : Number> methodMinus(vararg parameters: T): T

    @IMethod(values = IMethodType.METHOD_MULTIPLY)
    fun <T : Number> methodMultiply(vararg parameters: T): T

    @IMethod(values = IMethodType.METHOD_DIVIDE)
    fun <T : Number> methodDivide(vararg parameters: T): T
}

@Target(
    AnnotationTarget.FUNCTION,
)
@Retention(AnnotationRetention.RUNTIME)
annotation class IMethod(val values: Int = 0) {
}

@Target(
    AnnotationTarget.VALUE_PARAMETER,
)
@Retention(AnnotationRetention.RUNTIME)
@IntDef(
    IMethodType.METHOD_ADD,
    IMethodType.METHOD_MINUS,
    IMethodType.METHOD_MULTIPLY,
    IMethodType.METHOD_DIVIDE
)
annotation class IMethodType(@IMethodType val value: Int = METHOD_ADD) {
    companion object {
        const val METHOD_ADD = 0
        const val METHOD_MINUS = 1
        const val METHOD_MULTIPLY = 2
        const val METHOD_DIVIDE = 3
    }
}